/**
 * losenote.com Inc.
 * Copyright (c) 2013-2013 All Rights Reserved.
 */
package com.losenote.core.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.losenote.core.AttachFileComponent;
import com.losenote.model.AttachFile;
import com.losenote.model.ct.AttachFileConvertor;
import com.losenote.orm.AttachFileDO;
import com.losenote.orm.AttachFileDODAO;

/**
 * 文件操作组件
 * 
 * @author danjingyu
 * @version $Id: AttachFileComponentImpl.java, v 0.1 2013-9-12 下午10:58:27 danjingyu Exp $
 */
public class AttachFileComponentImpl implements AttachFileComponent {

    /**文件的根目录*/
    private String          baseDir;

    /**关联文件*/
    @Autowired
    private AttachFileDODAO attachFileDODAO;

    public List<AttachFile> queryByRelateFile(int relateId) {
        return null;
    }

    /** 
     * @see com.losenote.core.AttachFileComponent#saveFile()
     */
    @Override
    public AttachFile saveFile() {
        return null;
    }

    /** 
     * 读取文件
     * 
     * @see com.losenote.core.AttachFileComponent#readFile(int)
     */
    @Override
    public AttachFile readFile(int fileId) {
        AttachFileDO attachFileDO = attachFileDODAO.selectByPrimaryKey(fileId);
        return AttachFileConvertor.fromDo(attachFileDO, baseDir);
    }

    public void setBaseDir(String baseDir) {
        this.baseDir = baseDir;
    }

}
